using System;
using System.Collections.Generic;
using System.Text;
using FutureOpen.Core;
using FutureOpen.Core.func.db;

namespace FutureOpen.Core.func.cf
{
    public class RecommCat
    {
        private int catID;
        public RecommCat(int catID, List<RecommArt> arts)
        {
            this.catID = catID;
            this.arts = arts;
        }
        private List<RecommArt> arts;
        public List<RecommArt> Arts
        {
            get { return arts; }
            set { arts = value; }
        }       
    }

    public class JobCFManager : CFManager
    {
        public JobCFManager()
        {
            this.artType = ArtType.ARTTYPE_JOB;                        
        } 
    }
    
    public class CFManager
    {
        protected int artType;
        protected MyArt myart = null;
        protected MyCat mycat = null;
        protected Dictionary<int, RecommCat> mycats = null;

        public CFManager() { }
        private CFManager(int type)
        {
            this.artType = type;
        }

        public void Init()
        {
            mycats = new Dictionary<int, RecommCat>();
            mycat = new MyCat();
            LoadCats();
        }

        public void LoadCats()
        {
            IList<Cat> cats = mycat.GetChildren(CatType.CATTYPE_ROOT);
            this.mycats.Clear();
            foreach (Cat cat in cats)
            {
                IList<Art> arts = myart.GetCatArtByCount(cat.Cat_id, 50, this.artType);

                List<RecommArt> rarts = new List<RecommArt>();
                foreach (Art art in arts)
                {
                    RecommArt rart = new RecommArt(art);
                    rarts.Add(rart);
                }
                this.mycats.Add(cat.Cat_id, new RecommCat(cat.Cat_id, rarts));
            } 
        }

                 
    }
}
